<template>
	<view class="container">
		<view class="layout">
			<view class="redbox">
				<view class="money">¥{{ state.price }}</view>
				<view class="msg">冻结金额</view>
			</view>
			<view class="block-item">
				<view class="table" v-if="state.list.length">
					<view class="thead">
						<view class="th">设备ID</view>
						<view class="th">广告条数</view>
						<view class="th">广告总价值</view>
					</view>
					<view class="tbody">
						<view class="tr" v-for="(item, index) in state.list" :key="index">
							<view class="td one">{{ item.imei }}</view>
							<view class="td tow">{{ item.total }}</view>
							<view class="td three">￥{{ item.price }}</view>
						</view>
					</view>
				</view>
				<view class="empty" style="height: 70vh" v-else>
					<u-empty text="暂无数据" mode="list"></u-empty>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { get } from '@/request/index.js';

onLoad(() => {
	getListData();
});

onReachBottom(() => {
	state.page++;
	if (state.page > state.totalPage) return uni.showToast({ title: '我也是有底线的 ~' });
	getListData();
});

const state = reactive({
	price: 0,
	list: [],
	page: 1,
	totalPage: 1
});

const getListData = async () => {
	uni.showLoading({
		title: '数据请求中···'
	});
	const res = await get('agent/center/price_list', { type: 3 });
	const { code, data } = res;
	if (code == 200) {
		state.price = data.price;
		state.list = data.list.data;
		state.totalPage = data.list.last_page;
	}
	uni.hideLoading();
};
</script>

<style></style>
